package com.matrix.marketing.controller;

import com.matrix.api.marketing.vo.CheckInResultVO;
import com.matrix.api.marketing.vo.UserCouponVO;
import com.matrix.api.marketing.vo.UserPointsVO;
import com.matrix.common.domain.Result;
import com.matrix.marketing.service.MarketingUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 有点甜
 * @since 2025/8/1
 */
@RestController
@RequestMapping("/app/marketing")
@RequiredArgsConstructor
public class MarketingUserController {

    private final MarketingUserService marketingUserService;

    @PostMapping("/check-in")
    public Result<CheckInResultVO> checkIn(@RequestHeader("X-User-ID") Long userId) {
        return Result.success(marketingUserService.userCheckIn(userId));
    }

    @GetMapping("/my-coupons")
    public Result<List<UserCouponVO>> getMyCoupons(@RequestHeader("X-User-ID") Long userId,
                                                   @RequestParam(value="shopId", defaultValue="0") Long shopId) {
        return Result.success(marketingUserService.getMyCoupons(userId, shopId));
    }

    @GetMapping("/my-points")
    public Result<UserPointsVO> getMyPoints(@RequestHeader("X-User-ID") Long userId) {
        return Result.success(marketingUserService.getMyPoints(userId));
    }
}
